﻿using System;
using PowerToolsWeb.DataAccess;

namespace PowerToolsWeb
{
    public partial class ContactUs : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                BindCompanyInfo();            
        }
        void BindCompanyInfo()
        {
            Tpt_Companyinfo company = new Tpt_Companyinfo();
            if (company.GetCompanyInfo())
            {
                this.lblCompanyName.Text = company.COMPANYNAME;
                this.lblContact.Text = company.CONTACTOR;
                this.lblTel.Text = (company.CONTACTTEL == "") ? company.MOBILEPHONE : company.CONTACTTEL;
                this.lblAddress.Text = company.ADDRESS;
                if (company.QQ != "" && company.QQSIGKEY != "")
                {
                    string qqCode = @"<a href=""http://sighttp.qq.com/cgi-bin/check?sigkey=" + company.QQSIGKEY + @"""
                            target=""_blank"" onclick="" var 
                            tempSrc='http://sighttp.qq.com/wpa.js?rantime='+Math.random()+'&sigkey=" + company.QQSIGKEY + @"';
                            var oldscript=document.getElementById('testJs');
                            var newscript=document.createElement('script');newscript.setAttribute('type','text/javascript'); 
                            newscript.setAttribute('id','testJs');newscript.setAttribute('src',tempSrc);
                            if(oldscript == null){
                            document.body.appendChild(newscript);
                            }else{
                            oldscript.parentNode.replaceChild(newscript,oldscript);
                            }return false;"">
                            <img border=""0"" src='http://wpa.qq.com/pa?p=1:" + company.QQ + @":41' alt=""和我联系"" />
                            </a>";
                    this.lblQQ.Text = qqCode;
                }
            }
        }
    }
}
